<?php

?>
<div class="row-fluid">
	<div class="span12" style="text-align:center; margin-bottom:24px;">
		<a href="<?php echo Yii::app()->createUrl('app/mobile', array('download'=>1, 'type'=>'iphone')); ?>" target="_blank"><img src="<?php echo Yii::app()->baseUrl; ?>/img/app-store-icon.png" alg="Yamii in App Store" /></a>
		<a href="<?php echo Yii::app()->createUrl('app/mobile', array('download'=>1, 'type'=>'android')); ?>" target="_blank"><img src="<?php echo Yii::app()->baseUrl; ?>/img/google-play-icon.png" alg="Yamii in Google Play Store" /></a>
	</div>
</div>
<div class="row-fluid">
	<div class="span12">
		<p><?php echo BUtils::T('or_lbl'); ?></p>
		<p class="section-text" style="color:#333;"><?php echo BUtils::T('yamii_download_email_lbl'); ?></p>
		<form class="form-inline" id="download-form" action="<?php echo Yii::app()->createUrl('/app/subscribe'); ?>" method="post">
			<input class="enablewatermake" type="text" id="txt_email" name="txt_email" placeholder="<?php echo BUtils::T('email_enter_lbl'); ?>" />
			<?php echo CHtml::ajaxSubmitButton(BUtils::T('send_to_me_btn'),
					CHtml::normalizeUrl(array('/app/subscribe')),
					array(
						'error'=>'js:function(obj){ error(obj); }',
						'beforeSend'=>'js:function(obj){ beforeSend(obj); }',
						'success'=>'js:function(data){ success(data); }',
					),
					array('class' => 'btn btn-primary')); ?>
		</form>
		<div class="message_box" style="height:24px;margin-bottom:12px;">
			<span class="" id="loading_message" style="display:none;"><img src="<?php echo Yii::app()->baseUrl; ?>/img/ajax-loaders/ajax-loader-4.gif" alt="" /></span>
			<span class="" id="error_message" style="color:red;"></span>
			<span class="" id="success_message" style="color:green;"></span>
		</div>
	</div>
</div>
<div class="row-fluid">
	<div class="span12">
		<p><?php echo BUtils::T('or_lbl'); ?></p>
		<p class="section-text" style="color:#333;"><?php echo BUtils::T('yamii_download_scan_lbl'); ?></p>
		<div style="text-align:center;"><img src="<?php echo Yii::app()->baseUrl; ?>/img/yamii_qrcode.png" alt="" width="200" /></div>
	</div>
</div>
<script>
function error(obj) {
	$('#loading_message').hide();
	$('#success_message').html('').hide();
	$('#error_message').html('Network error!').show();
}
function beforeSend(obj) {
	$('#loading_message').show();
	$('#success_message').html('').hide();
	$('#error_message').html('').hide();
}
function success(data) {
	$('#loading_message').hide();
	var json = jQuery.parseJSON(data);
	if (json.code == 200) {
		$('#error_message').html('').hide();
		$('#success_message').html(json.message).show();
	} else {
		$('#success_message').html('').hide();
		$('#error_message').html(json.message).show();
	}
}
</script>
